package Review;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Wukong
 * Date: 2022-06-04
 * Time: 14:53
 */
public class Student implements Comparable<Student>{
    String name;
    int score;


    public Student(String name, int score) {
        this.name = name;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", score=" + score +
                '}';
    }
    @Override
    public int compareTo(Student o) {
        return this.score-o.score;
    }

    public static void main(String[] args) {
        Student student=new Student("lisa",20);
        Student student1=new Student("lusi",19);
        Student[] students=new Student[3];
        students[0]=new Student("lisa",20);
        students[1]=new Student("lusi",19);
        students[2]=new Student("luse",18);
        Arrays.sort(students);//按照数字顺序排列指定的数组。
        System.out.println("排序后"+Arrays.toString(students));//返回指定数组的内容的字符串表示形式
        int result=student.compareTo(student1);
        System.out.println(result);

    }


}
